package com.ruoyi.system.utils.rabbitMq.direct;
import com.ruoyi.system.enums.RabbitMqEnum;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author jzx
 * @title: DirectConfig
 * @projectName plat
 * @description: TODO
 * @date 2019-6-2410:24
 */
@Configuration
public class DirectConfig {

    @Bean
    public Queue queueBind() {
        return new Queue(RabbitMqEnum.KEYMAT_BIND.getCode(),true);
    }//队列持久化

    @Bean
    public Queue queueCollection() {
        return new Queue(RabbitMqEnum.DATA_COLLECTION.getCode(),true);
    }

    @Bean
    public Queue queuePushing() {
        return new Queue(RabbitMqEnum.MESSAGE_PUSHING.getCode(),true);
    }

    @Bean
    public Queue queueCasenumber() {
        return new Queue(RabbitMqEnum.DATA_CASENUMBER.getCode(),true);
    }

    @Bean
    public Queue queueLockedItem() {
        return new Queue(RabbitMqEnum.LOCKED_ITEM.getCode(),true);
    }

    @Bean
    public Queue queueUserInfo() {
        return new Queue(RabbitMqEnum.USER_INFO.getCode(),true);
    }

    @Bean
    public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory);
        factory.setAcknowledgeMode(AcknowledgeMode.MANUAL); // 设置手动确认模式
        return factory;
    }


}
